package com.danicsoft.daide.token;

import java.io.IOException;
import java.io.OutputStream;

/**
 * A <code>Token</code> that is invalid and cannot be parsed. It is only
 * useful for converting from text to tokens.
 * 
 * @author Daniel Yule (daniel.yule@gmail.com)
 * @version 1.0
 */
public class InvalidToken extends Token {

	/**
	 * The token that is invalid as a String
	 */
	private String badToken;

	/**
	 * Create a new invalid token for the given string. This string cannot be
	 * converted to a token.
	 * 
	 * @param problem
	 *        The string that cannot be converted to a token.
	 */
	public InvalidToken(String problem) {
		super(TokenMap.INVALID);
		badToken = problem;

	}

	@Override
	public Token clone() {
		return new InvalidToken(badToken);
	}

	@Override
	public Object getData() {
		return badToken;
	}

	@Override
	public int hashCode() {
		return badToken.hashCode();
	}

	@Override
	public void output(OutputStream output) throws IOException {
		output.write(badToken.getBytes());
	}

	@Override
	public String toString() {
		return badToken;
	}

}
